<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .container {
            width: 100%;
            padding-bottom: 1000px;
            background-color: red;
        }

        .title {
            position: sticky;
            top: 0;
            background-color: blue;
        }
    </style>
</head>

<body>
    <!-- 粘性定位 注意它的相对定位是相对于谁？ 相对于它父元素、祖先元素的第一个overflow的元素 -->
    <div class="container">
        我是一个div
        <div class="box">
            <div class="title">我是title</div>
            <div class="box1">我是box1</div>
            <div class="box1">我是box1</div>
        </div>
        <div class="box">
            <div class="title">我是title</div>
            <div class="box1">我是box1</div>
            <div class="box1">我是box1</div>
        </div>
    </div>
</body>

</html>